package com.zhss.springbootdemo01.validate;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * @ClassName AgeValidator
 * @Description TODO
 * @Author leejiliang
 * @DateTime 2021/2/6 22:00
 * @Version 1.0
 */
public class AgeValidator implements ConstraintValidator<Age, Integer> {
	private Integer min;
 	private Integer max;

	public void initialize(Age age) {
		this.min = age.min();
		this.max = age.max();
	}


	public boolean isValid(Integer value, ConstraintValidatorContext context) {
		return value <= max && value >= min;
	}


}
